#include <QDebug>
#include <QThread>
#include "imagecapture.h"



ImageCapture::ImageCapture(QObject *parent): QThread(parent)
{

}



void ImageCapture::run()
{

    VideoCapture camera(1);
    Mat frame;
    cv::Rect rect ;
    qRegisterMetaType<cv::Mat>("cv::Mat");

    while(1){

       qDebug()<< "running...";
       camera>>frame;
       if(frame.empty())
           continue;

//        emit display(QPixmap::fromImage(

//                         QImage(
//                             frame.data,
//                             frame.cols,
//                             frame.rows,
//                             frame.step,
//                             QImage::Format_RGB888
//                             ).rgbSwapped()));
       rect.x=frame.cols/2 -150;
       rect.y=frame.rows/2 -150;
       rect.width=300;
       rect.height=300;


       cv::rectangle(frame, rect, Scalar(255,0,0),3,LINE_8,0);

       emit display(frame);

    }




}
